package demo.liu.one.fegin;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.HashMap;
import java.util.Map;

/**
 * @author by Liujt
 * @Classname IDemoClient
 * @Description TODO
 * @Date 2021/6/1 18:37
 */
@FeignClient(name = "kjwy-demoTwo", fallback = IDemoTwoClient.IDemoClientFallback.class)
public interface IDemoTwoClient {

    @GetMapping("/test/feign")
    Map testFeign();

    @Slf4j
    @Component
    class IDemoClientFallback implements IDemoTwoClient {

        @Override
        public Map testFeign() {
            log.error("测试熔断");
            return new HashMap() {{
                this.put("msg", "远程已熔断");
            }};
        }
    }

}
